package cn.shutdown.demo.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import cn.shutdown.demo.dao.UserDao;

@Repository
public class UserDaoImpl implements UserDao {
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	@SuppressWarnings("deprecation")
	public int getMatchCount(String userName, String password){
		String sql = "select count(1) from demo_user where user_name = ? and password = ?";
		return jdbcTemplate.queryForInt(sql, new Object[]{userName, password});
	}

	@Override
	public void saveUser(String userName, String password) {
		String sql = "insert into demo_user (user_name,password) values(?,?)";
		jdbcTemplate.update(sql, new Object[]{userName, password});
	}
}
